<template>
	<view class="base-page">
		<view class="yangsf-padding-20 yangsf-flex-col-center">
			<view class="yangsf-m-t-200 yangsf-ratio-w-100 yangsf-flex-col-center">
				<u-code-input @confirm="confirm" v-model="payPassword" :maxlength="6" dot></u-code-input>
			</view>
			<view class="yangsf-m-t-200 yangsf-ratio-w-100 yangsf-flex-col-center">
				<view class="yangsf-ratio-w-80">
					<u-button type="primary" text="提交" @click="save"></u-button>
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	import {
		setPayPassword
	} from '@/config/api.js'
	import {
		domain
	} from '@/config/config'
	export default {
		data() {
			return {
				payPassword: ''
			}
		},
		methods: {
			save() {
				if (!this.payPassword) {
					uni.$u.toast("请设置支付密码")
					return
				}

				let data = {
					newPwd: this.payPassword
				}

				setPayPassword(data).then(res => {
					if (res.code == 200) {
						uni.$u.toast("设置成功")
						setTimeout(() => {
							window.location.href = domain
						}, 1000);
					} else {
						uni.$u.toast(res.msg)
					}
				})
			}
		}
	}
</script>

<style>

</style>